package com.my.test.user.ctrl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/manage")
public class UserAdminCtrl {

	@RequestMapping("/list")
	public String getList(){
		return "/manage/list";
	}
	@RequestMapping("/list2")
	public String getList2(){
		return "/manage/list2";
	}
	@RequestMapping("/list3")
	public String getList3(){
		return "/manage/list3";
	}
	
	@ResponseBody
    @RequestMapping("/listdo2")
    public Object listUsers2(HttpServletRequest request) throws IOException {
		ServletInputStream sis = request.getInputStream();
		
		Result r = new Result();
		List<Users> list = new ArrayList<Users>();
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		
		r.setDraw(1);
		r.setRecordsFiltered(5);
		r.setRecordsTotal(100);
		r.setList(list);
		return list;
    }
	@ResponseBody
    @RequestMapping("/listdo")
    public Object listUsers() {
		Result r = new Result();
		List<Users> list = new ArrayList<Users>();
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		list.add(Users.initUser());
		
		r.setTotal(list.size());
		r.setDraw(1);
		r.setRecordsFiltered(5);
		r.setRecordsTotal(100);
		r.setList(list);
		r.setRecords(list);
		return r;
    }
}
class Result{
	 private int draw;
	 
	 private int total;
	 private int  recordsFiltered;
	 private int recordsTotal;
	 private List<Users> list;
	 private List<Users> records;
	 
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public List<Users> getRecords() {
		return records;
	}
	public void setRecords(List<Users> records) {
		this.records = records;
	}
	public int getDraw() {
		return draw;
	}
	public void setDraw(int draw) {
		this.draw = draw;
	}
	public int getRecordsFiltered() {
		return recordsFiltered;
	}
	public void setRecordsFiltered(int recordsFiltered) {
		this.recordsFiltered = recordsFiltered;
	}
	public int getRecordsTotal() {
		return recordsTotal;
	}
	public void setRecordsTotal(int recordsTotal) {
		this.recordsTotal = recordsTotal;
	}
	public List<Users> getList() {
		return list;
	}
	public void setList(List<Users> list) {
		this.list = list;
	}
}
class Users{
	public static Users initUser(){
		Users u = new Users();
		u.setId(1);
		u.setInstitutionCode("123");
		u.setInstitutionName("hzb");
		u.setLoginId(1);
		u.setRealName("hzbb");
		u.setHomeAddress("test address");
		u.setCreateTime(new Date());
		return u ;
	}
	private int id;
	private String institutionCode;
	private String institutionName;
	private int loginId;
	private String realName;
	private Date createTime;
	private String homeAddress;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getInstitutionCode() {
		return institutionCode;
	}
	public void setInstitutionCode(String institutionCode) {
		this.institutionCode = institutionCode;
	}
	public String getInstitutionName() {
		return institutionName;
	}
	public void setInstitutionName(String institutionName) {
		this.institutionName = institutionName;
	}
	public int getLoginId() {
		return loginId;
	}
	public void setLoginId(int loginId) {
		this.loginId = loginId;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getHomeAddress() {
		return homeAddress;
	}
	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
	}
}
